using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace Daniel.Core.Models.Mapping
{
    public class SpecificationAttributeOptionMap : EntityTypeConfiguration<SpecificationAttributeOption>
    {
        public SpecificationAttributeOptionMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.Name)
                .IsRequired();

            // Table & Column Mappings
            this.ToTable("SpecificationAttributeOption");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.SpecificationAttributeId).HasColumnName("SpecificationAttributeId");
            this.Property(t => t.Name).HasColumnName("Name");
            this.Property(t => t.DisplayOrder).HasColumnName("DisplayOrder");

            // Relationships
            this.HasRequired(t => t.SpecificationAttribute)
                .WithMany(t => t.SpecificationAttributeOptions)
                .HasForeignKey(d => d.SpecificationAttributeId);

        }
    }
}
